<template>
  <div class="hello">
    <h2>常数类别管理</h2>

    <el-container>
      <el-header>
        <el-row>
          <el-col :xs="6" :sm="6" :md="6" :lg="6" :xl="3">
            <el-input v-model="input" placeholder="请输入常数类别编码或名称"></el-input>
          </el-col>

          <el-col :xs="6" :sm="6" :md="6" :lg="6" :xl="3">
            <el-button type="primary">查询常数类别</el-button>
          </el-col>

          <el-col :xs="6" :sm="6" :md="6" :lg="6" :xl="3">
            <el-button @click="dialogVisible=true" type="primary" icon="el-icon-edit">新增常数类别</el-button>
          </el-col>
          <el-dialog :visible.sync="dialogVisible">
            <span>新增常数类别</span><br>
            <el-form :inline="true" :model="addDrugForm" label-width="100px">
              <el-form-item label="常数类别编码">
                <!-- <el-col :span="24">
                <el-input v-model="addDrugForm.drugsCode" placeholder="常数类别编码" style="width: 100%;"></el-input>
                </el-col> -->
                <el-input v-model="addDrugForm.drugsCode" placeholder="常数类别编码"></el-input>
              </el-form-item>
              <el-form-item label="常数类别名称">
                <el-input v-model="addDrugForm.drugsName" placeholder="常数类别名称"></el-input>
              </el-form-item>
            </el-form>

            <span solt="footer" class="dialog-footer">
              <el-button @click="dialogVisible=false" type="warning">取消</el-button>
              <el-button type="primary" @click="addNewDrug()">保存</el-button>
            </span>
          </el-dialog>

          <el-col :xs="6" :sm="6" :md="6" :lg="6" :xl="3">
            <el-button @click="dialogVisible1=true" type="primary" icon="el-icon-edit">常数项管理</el-button>
          </el-col>
          <el-dialog :visible.sync="dialogVisible1">
            <span>常数项列表</span><br>
            <el-form :model="addDrugForm" label-width="100px">

              <el-col :xs="6" :sm="6" :md="6" :lg="6" :xl="3">
                <el-input v-model="input" placeholder="请输入常数类别编码或名称"></el-input>
              </el-col>

              <el-col :xs="6" :sm="6" :md="6" :lg="6" :xl="3">
                <el-select v-model="input" placeholder="所属分类">
                  <el-option label="区域一" value="shanghai"></el-option>
                  <el-option label="区域二" value="beijing"></el-option>
                </el-select>
              </el-col>

              <el-col :xs="6" :sm="6" :md="6" :lg="6" :xl="3">
                <el-button type="primary">查询常数项</el-button>
              </el-col>

              <el-col :xs="6" :sm="6" :md="6" :lg="6" :xl="3">
                <el-button @click="dialogVisible=true" type="primary" icon="el-icon-edit">新增常数项</el-button>
              </el-col>
            </el-form>

            <el-table :data="msg" style="width: 100%">
              <el-table-column prop="userName" label="常数项编码" width="180"></el-table-column>
              <el-table-column prop="realName" label="常数项名称" width="180"></el-table-column>
              <el-table-column prop="userName" label="常数项类别" width="180"></el-table-column>
              <el-table-column prop="realName" label="常数项ID" width="180"></el-table-column>
              <el-table-column label="操作"></el-table-column>
            </el-table>

            <span solt="footer1" class="dialog-footer1">
              <el-button @click="dialogVisible1=false" type="danger" icon="el-icon-delete">批量删除</el-button>
              <el-button type="primary" @click="addNewDrug()">关闭</el-button>
            </span>
          </el-dialog>
        </el-row>
      </el-header>
    </el-container>

    <el-button @click="submitClick">查询用户信息</el-button>
    <el-table :data="msg" style="width: 100%">
      <el-table-column prop="userName" label="类别编码" width="180"></el-table-column>
      <el-table-column prop="realName" label="类别名称" width="180"></el-table-column>
      <el-table-column label="ID"></el-table-column>
    </el-table>
  </div>
</template>

<script>
  export default {
    name: 'HelloWorld',
    mounted: function() {

    },
    data() {
      return {
        msg: [],
        dialogFormVisible: false,
        userName: '',
        password: '',
        realName: '',
        deptId: '',
        registLeId: '',
        deptIdList: [],
        registLeIdList: [],
        input: '',
        dialogVisible: false,
        addDrugForm: {
          drugsName: '',
          drugsCode: '',
          drugsPrice: '',
        },
        dialogVisible1: false,
      }
    },
    methods: {
      submitClick() {
        this.$axios.get("/neusys/user/queryAllUser")
          .then(response => {
            this.msg = response.data;
          })
      },
      getIdClick(index, row) {
        this.$axios.get("/neusys/user/update", {
            params: {
              id: this.msg[index].id,
              userName: this.msg[index].userName,
              realName: this.msg[index].password
            }
          })
          .then(response => {
            this.dialogFormVisible = true;
            this.userName = this.msg[index].userName;
            this.password = this.msg[index].password;
            this.realName = this.msg[index].realName;
            this.deptId = this.msg[index].deptId;
            this.registLeId = this.msg[index].registLeId;
            this.deptIdList = response.data.deptList.id;
            this.registLeIdList = response.data.regList.id;
          })
      },
      //增加药品
      addNewDrug() {
        this.$axios.post("/drugmage/addNewDrug", this.addDrugForm)
          .then(function(response) {
            console.log(response);
          })
        alert(this.addDrugForm.drugsName);
      }
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  h1,
  h2 {
    font-weight: normal;
  }

  ul {
    list-style-type: none;
    padding: 0;
  }

  li {
    display: inline-block;
    margin: 0 10px;
  }

  a {
    color: #42b983;
  }
</style>
